<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

$query1="select distinct a.artist,u.USERID,u.username,a.title,a.AUDIOID,a.AUDIOID from members u left join audios a  on(u.USERID=a.USERID) where u.status='1' and a.active='1' and a.artist!='' order by a.artist";
$executequery=$conn->execute($query1);
$results = $executequery->getrows();
$Headerartists=array();
$Headertitles=array();
$idSet=array();
$artistsRetrived=array();

$searchbar_category="";
if(isset($_REQUEST["cat"]))
{
    $searchbar_category=intval($_REQUEST["cat"]);
}else if(isset($_REQUEST["filter"])){
    $searchbar_category=intval($_REQUEST["filter"]);
}
STemplate::assign('searchbar_category',$searchbar_category);
foreach($results as $key=>$val){
    
	//if(!in_array($val["USERID"],$idSet)){
		$idSet[]=$val["USERID"];
		$artistName=trim(stripcslashes($val["artist"]));

		if(!in_array($artistName,$artistsRetrived) && $artistName!="")
			$Headerartists[]=array("artist"=>$artistName);
		$artistsRetrived[]=$artistName;	
	//}	
	$Headertitles[]=array("audioid"=>$val["AUDIOID"],"title"=>$val["title"]);	
}

$HeaderyearRange=range(Date("Y"),1970);

STemplate::assign('Headerartists',$Headerartists);
STemplate::assign('Headertitles',$Headertitles);
STemplate::assign('HeaderyearRange',$HeaderyearRange);
STemplate::assign('Headercountry',listHeaderCountries(""));

## function to get the list of the countries...
function listHeaderCountries($Headerselected){
	$Headercountry="";
    $Headercountries = array("Trinidad and Tobago","Barbados","Jamaica","Grenada","Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antartica","Antigua and Barbuda","Argentina","Armenia","Aruba","Ascension Island","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Botswana","Bouvet Island","Brazil","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde Islands","Cayman Islands","Chad","Chile","China","Christmas Island","Colombia","Comoros","Cook Islands","Costa Rica","Cote d Ivoire","Croatia/Hrvatska","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Guadeloupe","Guam","Guatemala","Guernsey","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Ireland","Isle of Man","Israel","Italy", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte Island", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Island", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion Island", "Romania", "Russian Federation", "Rwanda", "Saint Helena", "Saint Lucia", "San Marino", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia", "Spain", "Sri Lanka", "Suriname", "Svalbard", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tokelau", "Tonga Islands",  "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Western Sahara", "Western Samoa", "Yemen", "Yugoslavia", "Zambia","Zimbabwe");
    for($i=0;$i<count($Headercountries);$i++)
    {
    	if($Headerselected == $Headercountries[$i])
        {
			$Headercountry .="<option value=\"$Headercountries[$i]\" selected>$Headercountries[$i]</option>";
		}
        else
		{
			$Headercountry .="<option value=\"$Headercountries[$i]\">$Headercountries[$i]</option>";
		}
	}
	return $Headercountry;
 }

?>